package com.bskj.common.bean.model;

import java.util.Date;

/**
 * 
 * @author lishi
 * @date 2018年5月7日 上午12:15:11
 */
public class BmsResource extends BaseModels implements BaseModel, Comparable<BmsResource> {
	private Integer id;
	private String name; //'菜单/功能 名',
	private String url; //菜单链接/功能按钮对应的action
	private int level = 1; //菜单级别(1-一级菜单 2-子菜单  3-功能按钮 目前只支持3级)
	private Integer parentId; //父菜单ID（一级菜单父ID为0）
	private int sort = 100; //菜单顺序（序号越小越靠前）
	private Integer operator; //操作人ID（t_bms_user.id）
	private Date createTime;
	private Date updateTime;
	@Column
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}
	@Column
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	@Column
	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}
	@Column
	public int getLevel() {
		return level;
	}

	public void setLevel(int level) {
		this.level = level;
	}
	@Column
	public Integer getParentId() {
		return parentId;
	}

	public void setParentId(Integer parentId) {
		this.parentId = parentId;
	}
	@Column
	public int getSort() {
		return sort;
	}

	public void setSort(int sort) {
		this.sort = sort;
	}
	@Column
	public Integer getOperator() {
		return operator;
	}

	public void setOperator(Integer operator) {
		this.operator = operator;
	}
	@Column
	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	@Column
	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	//为了去重
	@Override
	public int hashCode() {
		if (id != null) {
			return id.hashCode();
		}
		return super.hashCode();
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}
		if (obj instanceof BmsResource) {
			BmsResource objResource = (BmsResource) obj;
			if (objResource.getId() != null && objResource.getId().equals(this.getId())) {
				return true;
			}
		}
		return false;
	}

	//为了排序
	public int compareTo(BmsResource o) {
		/**
		 * 需要满足 1、自反性    2、传递性   3、对称性
		 */
		if (o == this) {
			return 0;
		}
		if (o == null) {
			return 1;
		}
		
		return this.getSort() - o.getSort();
	}
}
 